package com.njym.java.security.admin.rest;

import com.njym.java.security.admin.biz.CirclePostBiz;
import com.njym.java.security.admin.entity.CirclePost;
import com.njym.java.security.common.rest.BaseController;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;


@Controller
@RequestMapping("circlePost")
public class CirclePostController extends BaseController<CirclePostBiz,CirclePost> {

    /**
     * 审核通过帖子
     * @param circlePost
     * @return
     */
    @RequestMapping(value = "/acceptPost",method = RequestMethod.POST)
    @ResponseBody
    public Object acceptGoods(@RequestBody CirclePost circlePost){
        int index = 1;
        //设置审核状态为1通过
        circlePost.setInvisible(index);
        System.out.println(circlePost);
        baseBiz.updateById(circlePost);
        return null;

    }

    /**
     * 审核不通过帖子
     * @param circlePost
     * @return
     */
    @RequestMapping(value = "/refusePost",method = RequestMethod.POST)
    @ResponseBody
    public Object refuseGoods(@RequestBody CirclePost circlePost){
        int index = 2;
        //设置审核状态为2拒绝
        circlePost.setInvisible(index);
        circlePost.setStatuses(0);
        circlePost.setStick(0);
        baseBiz.updateById(circlePost);
        return null;
    }

    /**
     *将帖子设为精华帖
     * @param circlePost
     * @return
     */
    @RequestMapping(value = "/addDigest",method = RequestMethod.POST)
    @ResponseBody
    public Object addDigest(@RequestBody CirclePost circlePost){
        circlePost.setStatuses(1);
        baseBiz.updateById(circlePost);
        return null;
    }

    /**
     *取消帖子精华
     * @param circlePost
     * @return
     */
    @RequestMapping(value = "/cancelDigest",method = RequestMethod.POST)
    @ResponseBody
    public Object cancelDigest(@RequestBody CirclePost circlePost){
        circlePost.setStatuses(0);
        baseBiz.updateById(circlePost);
        return null;
    }

    /**
     *将帖子设为置顶帖
     * @param circlePost
     * @return
     */
    @RequestMapping(value = "/addStick",method = RequestMethod.POST)
    @ResponseBody
    public Object addStick(@RequestBody CirclePost circlePost){
        circlePost.setStick(1);
        baseBiz.updateById(circlePost);
        return null;
    }

    /**
     *取消帖子置顶
     * @param circlePost
     * @return
     */
    @RequestMapping(value = "/cancelStick",method = RequestMethod.POST)
    @ResponseBody
    public Object cancelStick(@RequestBody CirclePost circlePost){
        circlePost.setStick(0);
        baseBiz.updateById(circlePost);
        return null;
    }



}